package com.itheima;

import com.itheima.config.SpringConfig;
import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;

public class App {
    public static void main(String[] args) {

        ApplicationContext app=new AnnotationConfigApplicationContext(SpringConfig.class);
        app.getBean("dataSource");
        UserService userService = (UserService) app.getBean("userService");


        User u1=new User();
        u1.setUsername("heima001");
        u1.setPassword("123");
       // userService.save(u1);

        List<User> list = userService.findAll();
        for (User user : list) {
            System.out.println(user);
        }
    }
}
